# file = open('./1.txt','r',encoding='utf-8')
# #路径不存在时，报错FileNotFound
# print(file.read())
# file.close()
import os
#自动关闭文件
# with open('./1.txt', 'r', encoding='utf-8') as file:
#     # print(file.read(2))
#     # print(file.read(1))
#     # print(file.readline().strip())
#     # print(file.readline().strip())
#     # print(file.readline().strip())
#     # print(file.readline().strip())
#     # list=file.readlines()
#     # print(list)
#     #read不加参数，代表读取所有参数
#     #readline代表读取有换行
#     #readlines输出为['avbSDSDVSDvsdV\n', 'b\n', 'c\n']
#     while True:
#         line = file.readline()
#         if not line:
#             break
#         print(line.strip())
#
# list = ['a1','b1','c1','d1','e1','f1']
# with open('./2.txt', 'a', encoding='utf-8')as file:
#     # file.write('hello world\n')
#     # file.write('我的祖国\n')
#     file.writelines(list)
#     print(list)

# with open('./a.png', 'rb') as file:
#     with open('D:/pycharm//20251106.png','wb')as file2:
#         while True:
#             data = file.read(1024)
#             if not data:
#                 break
#             file2.write(data)

# flag  = os.path.exists('D:/pycharm')
# flag2 = os.path.exists('D:/pycharm213')
# print(flag)
# print(flag2)
# os.makedirs('D:/pycharm213')
 #flag2 = os.path.exists('D:/pycharm213')
 #print(flag2)
 #os.rename('1.txt', '1111.txt')
 #print(os.getcwd())
 #print(os.listdir('.'))
for root, dirs, files in os.walk('D:'):
    print(root)
    print('-----------------1')
    print(dirs)
    print('-----------------2')
    print(files)
    print('-----------------3')